﻿{extend name="admin/common/blank"/}
	{block name="main"}
             
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>{$name}</legend>
</fieldset>
	<form class="layui-form" method="post" >
	
	{volist name="fields" id="data"}
		{if condition="strtoupper($data.input) eq 'UEDITOR'"}
			<div class="layui-form-item">
			<label class="layui-form-label">{$data.column_comment}</label>
			<div class="layui-input-block">
			  <script type="text/plain" name="content" id="myEditor" style="width:750px;height:240px;"><p>{$data.value}</p></script>
			</div>
			</div>
			
		{else/}
			{if condition="$data.column_name neq 'id' and $data.column_name neq 'up_time'" }
				
				{if condition="$data.input eq 'select'"}
				<div class="layui-form-item">
				<label class="layui-form-label">{$data.column_comment}</label>
				<div class="layui-input-block">
				  <select name="{$data.column_name}" lay-filter="aihao">
					<option value="" ></option>
					
					{volist name="$data.value" id="vo"}
						{if condition="$data.selectvalue eq $vo.id"}
						<option value="{$vo.id}" selected>{$vo.title}</option>
						{else/}
						<option value="{$vo.id}" >{$vo.title}</option>
						{/if}
					{/volist}
				</select>
				</div>
			</div>
				{else/}
			<div class="layui-form-item">
				<label class="layui-form-label">{$data.column_comment}</label>
				<div class="layui-input-block">
				  <input type="{$data.input}" name="{$data.column_name}" value="{empty name='$data.value'}{else /}{$data.value}{/empty}"  lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
				</div>
			</div>
				{/if}
				{else/}
				<input type="hidden" name="{$data.column_name}" value="{empty name='$data.value'}{else /}{$data.value}{/empty}"/>
				
			{/if}
		{/if}
		
	{/volist}
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
      
    </div>
  </div>
</form>

<script>
//实例化编辑器
    var ue = UE.getEditor('myEditor',{enterTag:'' ,});
	
layui.use(['form', 'layedit', 'laydate'], function(){
  var form = layui.form
  ,layer = layui.layer
  ,layedit = layui.layedit
  ,laydate = layui.laydate;
  
  //日期
  laydate.render({
    elem: '#date'
  });
  laydate.render({
    elem: '#date1'
  });
  

  
  //监听指定开关
  form.on('switch(switchTest)', function(data){
    layer.msg('开关checked：'+ (this.checked ? 'true' : 'false'), {
      offset: '6px'
    });
    layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
  });
  
  //监听提交
  form.on('submit(demo1)', function(data){
	$.ajax({
            //几个参数需要注意一下
                type: "post",//方法类型
                dataType: "json",//预期服务器返回的数据类型
				async:true,
                url: "{:url('admin/service/edit','','')}" ,//url
                data: {'data':data.field,'table':'{$table}'},
                success: function (result) {
                    window.parent.location.reload();
					var index = parent.layer.getFrameIndex(window.name);
					parent.layer.close(index);
					
                },
                error : function() {
					var index=parent.layer.getFrameIndex(window.name);
					parent.layer.close(index);
					window.parent.location.reload();  
                }
				
            });
	
			  });
			  
			  
			});
			function closePageForm(){
			  window.opener=null;
			  window.open('','_self');
			  window.close();
			}
</script>
		
	{/block}